<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="MongoDB 基本介绍, 夏天">
    <meta name="description" content="爱一直在线">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>MongoDB 基本介绍 | 夏天</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery.min.js"></script>
    <script src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8"></script>
<style type="text/css" lang="css">
    #loading-container{
        position: fixed;
        top: 0;
        left: 0;
        min-height: 100vh;
        width: 100vw;
        z-index: 9999;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        background: #FFF;
        text-align: center;
        /* loader页面消失采用渐隐的方式*/
        -webkit-transition: opacity 1s ease;
        -moz-transition: opacity 1s ease;
        -o-transition: opacity 1s ease;
        transition: opacity 1s ease;
    }
    .loading-image{
        width: 120px;
        height: 50px;
        transform: translate(-50%);
    }

    .loading-image div:nth-child(2) {
        -webkit-animation: pacman-balls 1s linear 0s infinite;
        animation: pacman-balls 1s linear 0s infinite
    }

    .loading-image div:nth-child(3) {
        -webkit-animation: pacman-balls 1s linear .33s infinite;
        animation: pacman-balls 1s linear .33s infinite
    }

    .loading-image div:nth-child(4) {
        -webkit-animation: pacman-balls 1s linear .66s infinite;
        animation: pacman-balls 1s linear .66s infinite
    }

    .loading-image div:nth-child(5) {
        -webkit-animation: pacman-balls 1s linear .99s infinite;
        animation: pacman-balls 1s linear .99s infinite
    }

   .loading-image div:first-of-type {
        width: 0;
        height: 0;
        border: 25px solid #49b1f5;
        border-right-color: transparent;
        border-radius: 25px;
        -webkit-animation: rotate_pacman_half_up .5s 0s infinite;
        animation: rotate_pacman_half_up .5s 0s infinite;
    }
    .loading-image div:nth-child(2) {
        width: 0;
        height: 0;
        border: 25px solid #49b1f5;
        border-right-color: transparent;
        border-radius: 25px;
        -webkit-animation: rotate_pacman_half_down .5s 0s infinite;
        animation: rotate_pacman_half_down .5s 0s infinite;
        margin-top: -50px;
    }
    @-webkit-keyframes rotate_pacman_half_up {0% {transform: rotate(270deg)}50% {transform: rotate(1turn)}to {transform: rotate(270deg)}}

    @keyframes rotate_pacman_half_up {0% {transform: rotate(270deg)}50% {transform: rotate(1turn)}to {transform: rotate(270deg)}}

    @-webkit-keyframes rotate_pacman_half_down {0% {transform: rotate(90deg)}50% {transform: rotate(0deg)}to {transform: rotate(90deg)}}

    @keyframes rotate_pacman_half_down {0% {transform: rotate(90deg)}50% {transform: rotate(0deg)}to {transform: rotate(90deg)}}

    @-webkit-keyframes pacman-balls {75% {opacity: .7}to {transform: translate(-100px, -6.25px)}}

    @keyframes pacman-balls {75% {opacity: .7}to {transform: translate(-100px, -6.25px)}}


    .loading-image div:nth-child(3),
    .loading-image div:nth-child(4),
    .loading-image div:nth-child(5),
    .loading-image div:nth-child(6){
        background-color: #49b1f5;
        width: 15px;
        height: 15px;
        border-radius: 100%;
        margin: 2px;
        width: 10px;
        height: 10px;
        position: absolute;
        transform: translateY(-6.25px);
        top: 25px;
        left: 100px;
    }
    .loading-text{
        margin-bottom: 20vh;
        text-align: center;
        color: #2c3e50;
        font-size: 2rem;
        box-sizing: border-box;
        padding: 0 10px;
        text-shadow: 0 2px 10px rgba(0,0,0,0.2);
    }
    @media only screen and (max-width: 500px) {
         .loading-text{
            font-size: 1.5rem;
         }
    }
    .fadeout {
        opacity: 0;
        filter: alpha(opacity=0);
    }
    /* logo出现动画 */
    @-webkit-keyframes fadeInDown{0%{opacity:0;-webkit-transform:translate3d(0,-100%,0);transform:translate3d(0,-100%,0)}100%{opacity:1;-webkit-transform:none;transform:none}}
    @keyframes fadeInDown{0%{opacity:0;-webkit-transform:translate3d(0,-100%,0);}}
 </style>
 <script>
(function () {
    const loaded = function(){
       setTimeout(function(){
            const loader = document.getElementById("loading-container");
            loader.className="fadeout" ;//使用渐隐的方法淡出loading page
            // document.getElementById("body-wrap").style.display="flex";
            setTimeout(function(){
                loader.style.display="none";
            },1000); 
        },1000);//强制显示loading page 1s  
    };
    loaded();
})()
 </script><meta name="generator" content="Hexo 4.2.0"><link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"><style type="text/css" lang="css">
    #loading-container{
        position: fixed;
        top: 0;
        left: 0;
        min-height: 100vh;
        width: 100vw;
        z-index: 9999;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        background: #FFF;
        text-align: center;
        /* loader页面消失采用渐隐的方式*/
        -webkit-transition: opacity 1s ease;
        -moz-transition: opacity 1s ease;
        -o-transition: opacity 1s ease;
        transition: opacity 1s ease;
    }
    .loading-image{
        width: 120px;
        height: 50px;
        transform: translate(-50%);
    }

    .loading-image div:nth-child(2) {
        -webkit-animation: pacman-balls 1s linear 0s infinite;
        animation: pacman-balls 1s linear 0s infinite
    }

    .loading-image div:nth-child(3) {
        -webkit-animation: pacman-balls 1s linear .33s infinite;
        animation: pacman-balls 1s linear .33s infinite
    }

    .loading-image div:nth-child(4) {
        -webkit-animation: pacman-balls 1s linear .66s infinite;
        animation: pacman-balls 1s linear .66s infinite
    }

    .loading-image div:nth-child(5) {
        -webkit-animation: pacman-balls 1s linear .99s infinite;
        animation: pacman-balls 1s linear .99s infinite
    }

   .loading-image div:first-of-type {
        width: 0;
        height: 0;
        border: 25px solid #49b1f5;
        border-right-color: transparent;
        border-radius: 25px;
        -webkit-animation: rotate_pacman_half_up .5s 0s infinite;
        animation: rotate_pacman_half_up .5s 0s infinite;
    }
    .loading-image div:nth-child(2) {
        width: 0;
        height: 0;
        border: 25px solid #49b1f5;
        border-right-color: transparent;
        border-radius: 25px;
        -webkit-animation: rotate_pacman_half_down .5s 0s infinite;
        animation: rotate_pacman_half_down .5s 0s infinite;
        margin-top: -50px;
    }
    @-webkit-keyframes rotate_pacman_half_up {0% {transform: rotate(270deg)}50% {transform: rotate(1turn)}to {transform: rotate(270deg)}}

    @keyframes rotate_pacman_half_up {0% {transform: rotate(270deg)}50% {transform: rotate(1turn)}to {transform: rotate(270deg)}}

    @-webkit-keyframes rotate_pacman_half_down {0% {transform: rotate(90deg)}50% {transform: rotate(0deg)}to {transform: rotate(90deg)}}

    @keyframes rotate_pacman_half_down {0% {transform: rotate(90deg)}50% {transform: rotate(0deg)}to {transform: rotate(90deg)}}

    @-webkit-keyframes pacman-balls {75% {opacity: .7}to {transform: translate(-100px, -6.25px)}}

    @keyframes pacman-balls {75% {opacity: .7}to {transform: translate(-100px, -6.25px)}}


    .loading-image div:nth-child(3),
    .loading-image div:nth-child(4),
    .loading-image div:nth-child(5),
    .loading-image div:nth-child(6){
        background-color: #49b1f5;
        width: 15px;
        height: 15px;
        border-radius: 100%;
        margin: 2px;
        width: 10px;
        height: 10px;
        position: absolute;
        transform: translateY(-6.25px);
        top: 25px;
        left: 100px;
    }
    .loading-text{
        margin-bottom: 20vh;
        text-align: center;
        color: #2c3e50;
        font-size: 2rem;
        box-sizing: border-box;
        padding: 0 10px;
        text-shadow: 0 2px 10px rgba(0,0,0,0.2);
    }
    @media only screen and (max-width: 500px) {
         .loading-text{
            font-size: 1.5rem;
         }
    }
    .fadeout {
        opacity: 0;
        filter: alpha(opacity=0);
    }
    /* logo出现动画 */
    @-webkit-keyframes fadeInDown{0%{opacity:0;-webkit-transform:translate3d(0,-100%,0);transform:translate3d(0,-100%,0)}100%{opacity:1;-webkit-transform:none;transform:none}}
    @keyframes fadeInDown{0%{opacity:0;-webkit-transform:translate3d(0,-100%,0);}}
 </style>
 <script>
(function () {
    const loaded = function(){
       setTimeout(function(){
            const loader = document.getElementById("loading-container");
            loader.className="fadeout" ;//使用渐隐的方法淡出loading page
            // document.getElementById("body-wrap").style.display="flex";
            setTimeout(function(){
                loader.style.display="none";
            },1000); 
        },1000);//强制显示loading page 1s  
    };
    loaded();
})()
 </script></head>



 <div id="loading-container">
     <p class="loading-text">玩命加载中 . . . </p> 
     <div class="loading-image">
         <div></div>
         <div></div>
         <div></div>
         <div></div> 
         <div></div>
     </div>
 </div><body>    
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">夏天</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>主页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="" class="waves-effect waves-light">

      
      <span>百宝箱</span>
      <i class="fas fa-chevron-down" aria-hidden="true" style="zoom: 0.6;"></i>
    </a>
    <ul class="sub-nav menus_item_child ">
      
      <li>
        <a href="https://caimengzhi.gitee.io/webstack/cn/index.html">
          
          <i class="fas fa-briefcase" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>宝箱一</span>
        </a>
      </li>
      
      <li>
        <a href="https://caimengzhi.gitee.io/nav/">
          
          <i class="fas fa-briefcase" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>宝箱二</span>
        </a>
      </li>
      
    </ul>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="" class="waves-effect waves-light">

      
      <i class="fas fa-sitemap" style="zoom: 0.6;"></i>
      
      <span>统计</span>
      <i class="fas fa-chevron-down" aria-hidden="true" style="zoom: 0.6;"></i>
    </a>
    <ul class="sub-nav menus_item_child ">
      
      <li>
        <a href="/tags">
          
          <i class="fas fa-tags" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>标签</span>
        </a>
      </li>
      
      <li>
        <a href="/categories">
          
          <i class="fas fa-bookmark" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>分类</span>
        </a>
      </li>
      
      <li>
        <a href="/archives">
          
          <i class="fas fa-archive" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>归档</span>
        </a>
      </li>
      
    </ul>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="" class="waves-effect waves-light">

      
      <i class="fa fa-gamepad" style="zoom: 0.6;"></i>
      
      <span>游戏</span>
      <i class="fas fa-chevron-down" aria-hidden="true" style="zoom: 0.6;"></i>
    </a>
    <ul class="sub-nav menus_item_child ">
      
      <li>
        <a href="https://caimengzhi.gitee.io/magiccube/">
          
          <i class="fa fa-money" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>魔方</span>
        </a>
      </li>
      
      <li>
        <a href="https://caimengzhi.gitee.io/game-2048">
          
          <i class="fa fa-money" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>2048</span>
        </a>
      </li>
      
    </ul>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="" class="waves-effect waves-light">

      
      <i class="fas fa-list" style="zoom: 0.6;"></i>
      
      <span>知识库</span>
      <i class="fas fa-chevron-down" aria-hidden="true" style="zoom: 0.6;"></i>
    </a>
    <ul class="sub-nav menus_item_child ">
      
      <li>
        <a href="https://caimengzhi.gitee.io/java/">
          
          <i class="fas fa-music" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>JAVA</span>
        </a>
      </li>
      
      <li>
        <a href="https://caimengzhi.gitee.io/mysql/">
          
          <i class="fas fa-film" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>MySQL</span>
        </a>
      </li>
      
      <li>
        <a href="https://caimengzhi.gitee.io/nosql/">
          
          <i class="fas fa-book" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>NoSQL</span>
        </a>
      </li>
      
      <li>
        <a href="https://caimengzhi.gitee.io/oracle/">
          
          <i class="fas fa-image" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>oracle</span>
        </a>
      </li>
      
      <li>
        <a href="https://caimengzhi.gitee.io/structure">
          
          <i class="fas fa-image" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>算法</span>
        </a>
      </li>
      
      <li>
        <a href="https://caimengzhi.gitee.io/hadoop/">
          
          <i class="fas fa-image" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>大数据</span>
        </a>
      </li>
      
      <li>
        <a href="https://caimengzhi.gitee.io/docker">
          
          <i class="fas fa-image" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>K8S</span>
        </a>
      </li>
      
      <li>
        <a href="https://caimengzhi.gitee.io/frontend/">
          
          <i class="fas fa-image" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>前端</span>
        </a>
      </li>
      
    </ul>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="" class="waves-effect waves-light">

      
      <span>联系</span>
      <i class="fas fa-chevron-down" aria-hidden="true" style="zoom: 0.6;"></i>
    </a>
    <ul class="sub-nav menus_item_child ">
      
      <li>
        <a href="/contact">
          
          <i class="fas fa-comments" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>联系</span>
        </a>
      </li>
      
      <li>
        <a href="/about">
          
          <i class="fas fa-user-circle" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>关于</span>
        </a>
      </li>
      
      <li>
        <a href="/friends">
          
          <i class="fas fa-address-book" style="margin-top: -20px; zoom: 0.6;"></i>
          
          <span>友链</span>
        </a>
      </li>
      
    </ul>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="https://news.qq.com/zt2020/page/feiyan.htm#/?nojump=1" target="_blank" rel="noopener" class="waves-effect waves-light">
      
      <i class="fas fa-heartbeat" style="zoom: 0.6;"></i>
      
      <span>疫情</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>

<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">夏天</div>
        <div class="logo-desc">
            
            爱一直在线
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			主页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="javascript:;">
			
				<i class="fas fa-fw fa-link"></i>
			
			百宝箱
			<span class="m-icon"><i class="fas fa-chevron-right"></i></span>
		</a>
            <ul  style="background:  ;" >
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/webstack/cn/index.html " style="margin-left:50px";>
				  
				   <i class="fa fas fa-briefcase" style="position: absolute;left:28px" ></i>
			      
		          <span>宝箱一</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/nav/ " style="margin-left:50px";>
				  
				   <i class="fa fas fa-briefcase" style="position: absolute;left:28px" ></i>
			      
		          <span>宝箱二</span>
                  </a>
                </li>
               
            </ul>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="javascript:;">
			
				<i class="fa-fw fas fa-sitemap"></i>
			
			统计
			<span class="m-icon"><i class="fas fa-chevron-right"></i></span>
		</a>
            <ul  style="background:  ;" >
              
                <li>   
				
                  <a href="/tags " style="margin-left:50px";>
				  
				   <i class="fa fas fa-tags" style="position: absolute;left:28px" ></i>
			      
		          <span>标签</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="/categories " style="margin-left:50px";>
				  
				   <i class="fa fas fa-bookmark" style="position: absolute;left:28px" ></i>
			      
		          <span>分类</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="/archives " style="margin-left:50px";>
				  
				   <i class="fa fas fa-archive" style="position: absolute;left:28px" ></i>
			      
		          <span>归档</span>
                  </a>
                </li>
               
            </ul>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="javascript:;">
			
				<i class="fa-fw fa fa-gamepad"></i>
			
			游戏
			<span class="m-icon"><i class="fas fa-chevron-right"></i></span>
		</a>
            <ul  style="background:  ;" >
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/magiccube/ " style="margin-left:50px";>
				  
				   <i class="fa fa fa-money" style="position: absolute;left:28px" ></i>
			      
		          <span>魔方</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/game-2048 " style="margin-left:50px";>
				  
				   <i class="fa fa fa-money" style="position: absolute;left:28px" ></i>
			      
		          <span>2048</span>
                  </a>
                </li>
               
            </ul>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="javascript:;">
			
				<i class="fa-fw fas fa-list"></i>
			
			知识库
			<span class="m-icon"><i class="fas fa-chevron-right"></i></span>
		</a>
            <ul  style="background:  ;" >
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/java/ " style="margin-left:50px";>
				  
				   <i class="fa fas fa-music" style="position: absolute;left:28px" ></i>
			      
		          <span>JAVA</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/mysql/ " style="margin-left:50px";>
				  
				   <i class="fa fas fa-film" style="position: absolute;left:28px" ></i>
			      
		          <span>MySQL</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/nosql/ " style="margin-left:50px";>
				  
				   <i class="fa fas fa-book" style="position: absolute;left:28px" ></i>
			      
		          <span>NoSQL</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/oracle/ " style="margin-left:50px";>
				  
				   <i class="fa fas fa-image" style="position: absolute;left:28px" ></i>
			      
		          <span>oracle</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/structure " style="margin-left:50px";>
				  
				   <i class="fa fas fa-image" style="position: absolute;left:28px" ></i>
			      
		          <span>算法</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/hadoop/ " style="margin-left:50px";>
				  
				   <i class="fa fas fa-image" style="position: absolute;left:28px" ></i>
			      
		          <span>大数据</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/docker " style="margin-left:50px";>
				  
				   <i class="fa fas fa-image" style="position: absolute;left:28px" ></i>
			      
		          <span>K8S</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="https://caimengzhi.gitee.io/frontend/ " style="margin-left:50px";>
				  
				   <i class="fa fas fa-image" style="position: absolute;left:28px" ></i>
			      
		          <span>前端</span>
                  </a>
                </li>
               
            </ul>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="javascript:;">
			
				<i class="fas fa-fw fa-link"></i>
			
			联系
			<span class="m-icon"><i class="fas fa-chevron-right"></i></span>
		</a>
            <ul  style="background:  ;" >
              
                <li>   
				
                  <a href="/contact " style="margin-left:50px";>
				  
				   <i class="fa fas fa-comments" style="position: absolute;left:28px" ></i>
			      
		          <span>联系</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="/about " style="margin-left:50px";>
				  
				   <i class="fa fas fa-user-circle" style="position: absolute;left:28px" ></i>
			      
		          <span>关于</span>
                  </a>
                </li>
              
                <li>   
				
                  <a href="/friends " style="margin-left:50px";>
				  
				   <i class="fa fas fa-address-book" style="position: absolute;left:28px" ></i>
			      
		          <span>友链</span>
                  </a>
                </li>
               
            </ul>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="https://news.qq.com/zt2020/page/feiyan.htm#/?nojump=1" target="_blank" rel="noopener" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-heartbeat"></i>
			
			疫情
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://caimengzhi.gitee.io/books/" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>

        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://caimengzhi.gitee.io/books/" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    
<script src="/libs/cryptojs/crypto-js.min.js"></script>
<script>
    (function() {
        let pwd = '';
        if (pwd && pwd.length > 0) {
            if (pwd !== CryptoJS.SHA256(prompt('您好，BOSS,请输入密码')).toString(CryptoJS.enc.Hex)) {
                alert('哈哈密码错了！！！');
                location.href = '/';
            }
        }
    })();
</script>




<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/10.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">MongoDB 基本介绍</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        height: calc(100vh - 250px);
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/NoSQL/">
                                <span class="chip bg-color">NoSQL</span>
                            </a>
                        
                            <a href="/tags/%E5%AD%A6%E4%B9%A0/">
                                <span class="chip bg-color">学习</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/MongoDB/" class="post-category">
                                MongoDB
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2020-03-23
                </div>
                

                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-check fa-fw"></i>更新日期:&nbsp;&nbsp;
                    2020-03-24
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>文章字数:&nbsp;&nbsp;
                    3.5k
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-clock fa-fw"></i>阅读时长:&nbsp;&nbsp;
                    15 分
                </div>
                

                
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="far fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>

        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <h2 id="1-介绍"><a href="#1-介绍" class="headerlink" title="1. 介绍"></a>1. 介绍</h2><h3 id="1-1-MongoDB"><a href="#1-1-MongoDB" class="headerlink" title="1.1 MongoDB"></a>1.1 MongoDB</h3><p>&emsp;&emsp;MongoDB 是由C++语言编写的，是一个基于分布式文件存储的开源数据库系统。在高负载的情况下，添加更多的节点，可以保证服务器性能。MongoDB 旨在为WEB应用提供可扩展的高性能数据存储解决方案。</p>
<p>&emsp;&emsp;MongoDB 将数据存储为一个文档，数据结构由键值(key=&gt;value)对组成。MongoDB 文档类似于 JSON 对象。字段值可以包含其他文档，数组及文档数组。</p>
<p><img src="https://gitee.com/caimengzhi/picBlog/raw/master///20200323100100.png" alt=""></p>
<h3 id="1-2-特点"><a href="#1-2-特点" class="headerlink" title="1.2 特点"></a>1.2 特点</h3><ul>
<li>MongoDB 是一个面向文档存储的数据库，操作起来比较简单和容易。</li>
<li>你可以在MongoDB记录中设置任何属性的索引 (如：FirstName=”Sameer”,Address=”8 Gandhi Road”)来实现更快的排序。</li>
<li>你可以通过本地或者网络创建数据镜像，这使得MongoDB有更强的扩展性。</li>
<li>如果负载的增加（需要更多的存储空间和更强的处理能力） ，它可以分布在计算机网络中的其他节点上这就是所谓的分片。</li>
<li>Mongo支持丰富的查询表达式。查询指令使用JSON形式的标记，可轻易查询文档中内嵌的对象及数组。</li>
<li>MongoDb 使用update()命令可以实现替换完成的文档（数据）或者一些指定的数据字段 。</li>
<li>Mongodb中的Map/reduce主要是用来对数据进行批量处理和聚合操作。</li>
<li>Map和Reduce。Map函数调用emit(key,value)遍历集合中所有的记录，将key与value传给Reduce函数进行处理。</li>
<li>Map函数和Reduce函数是使用Javascript编写的，并可以通过db.runCommand或mapreduce命令来执行MapReduce操作。</li>
<li>GridFS是MongoDB中的一个内置功能，可以用于存放大量小文件。</li>
<li>MongoDB允许在服务端执行脚本，可以用Javascript编写某个函数，直接在服务端执行，也可以把函数的定义存储在服务端，下次直接调用即可。</li>
<li>MongoDB支持各种编程语言:RUBY，PYTHON，JAVA，C++，PHP，C#等多种语言。</li>
<li>MongoDB安装简单。</li>
</ul>
<h2 id="2-安装"><a href="#2-安装" class="headerlink" title="2. 安装"></a>2. 安装</h2><h3 id="2-1-下载安装"><a href="#2-1-下载安装" class="headerlink" title="2.1 下载安装"></a>2.1 下载安装</h3><p>下载地址: <a href="https://www.mongodb.com/download-center/community" target="_blank" rel="noopener">https://www.mongodb.com/download-center/community</a></p>
<pre class=" language-shell"><code class="language-shell">[root@leco src]# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.6.tgz
--2019-02-27 09:42:36--  https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.6.tgz
Resolving fastdl.mongodb.org... 13.33.186.136, 13.33.186.26, 13.33.186.247, ...
Connecting to fastdl.mongodb.org|13.33.186.136|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 73265692 (70M) [application/x-gzip]
Saving to: “mongodb-linux-x86_64-4.0.6.tgz”

100%[=============================================================================================================================================>] 73,265,692  1021K/s   in 98s

2019-02-27 09:44:15 (733 KB/s) - “mongodb-linux-x86_64-4.0.6.tgz” saved [73265692/73265692]
</code></pre>
<h3 id="2-2-安装"><a href="#2-2-安装" class="headerlink" title="2.2 安装"></a>2.2 安装</h3><pre class=" language-shell"><code class="language-shell">[root@leco src]# tar xf mongodb-linux-x86_64-4.0.6.tgz
[root@leco src]# cd mongodb-linux-x86_64-4.0.6
[root@leco mongodb-linux-x86_64-4.0.6]# ls
bin  LICENSE-Community.txt  MPL-2  README  THIRD-PARTY-NOTICES
[root@leco src]# mv mongodb-linux-x86_64-4.0.6 /usr/local/
[root@leco src]# cd /usr/local/
[root@leco local]# ln -sf mongodb-linux-x86_64-4.0.6/ mongo</code></pre>
<p>注意</p>
<pre class=" language-python"><code class="language-python">我使用的是二进制包，直接解压即可使用，可以根据自己情况安装方式，
<span class="token number">1</span><span class="token punctuation">.</span> 二进制安装
<span class="token number">2</span><span class="token punctuation">.</span> 在线安装
<span class="token number">3</span><span class="token punctuation">.</span> 离线安装</code></pre>
<h3 id="2-3-添加环境变量"><a href="#2-3-添加环境变量" class="headerlink" title="2.3 添加环境变量"></a>2.3 添加环境变量</h3><ul>
<li>临时生效<code>[重启后就没了]</code></li>
</ul>
<pre><code>[root@leco local]# export PATH=/usr/local/mongo/bin:$PATH</code></pre><ul>
<li>永久生效</li>
</ul>
<pre><code>[root@leco mongo]# tail -2 /etc/profile
# add by caimengzhi for mongodb 4.0
export PATH=/usr/local/mongo/bin:$PATH
[root@leco mongo]# source /etc/profile</code></pre><h3 id="2-4-配置"><a href="#2-4-配置" class="headerlink" title="2.4 配置"></a>2.4 配置</h3><pre class=" language-shell"><code class="language-shell">[root@leco ~]# cd /usr/local/mongo
[root@leco mongo]# ls
bin  LICENSE-Community.txt  MPL-2  README  THIRD-PARTY-NOTICES
[root@leco mongo]# mkdir conf
[root@leco mongo]# mkdir -p /usr/local/mongodb/data/db
[root@leco mongo]# mkdir -p /usr/local/mongodb/logs
[root@leco mongo]# cd conf/
[root@leco conf]# vim mongodb.conf
[root@leco conf]# cat mongodb.conf
dbpath = /usr/local/mongodb/data/db
logpath = /usr/local/mongodb/logs/mongodb.log
port = 27017
fork = true
bind_ip=0.0.0.0
[root@leco mongo]# tree .
.
├── bin
│   ├── bsondump
│   ├── install_compass
│   ├── mongo
│   ├── mongod
│   ├── mongodump
│   ├── mongoexport
│   ├── mongofiles
│   ├── mongoimport
│   ├── mongoreplay
│   ├── mongorestore
│   ├── mongos
│   ├── mongostat
│   └── mongotop
├── conf
│   └── mongodb.conf
├── LICENSE-Community.txt
├── MPL-2
├── README
└── THIRD-PARTY-NOTICES

2 directories, 18 file</code></pre>
<h3 id="2-5-启动"><a href="#2-5-启动" class="headerlink" title="2.5 启动"></a>2.5 启动</h3><pre class=" language-shell"><code class="language-shell">[root@leco mongo]# mongod -f /usr/local/mongo/conf/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 18924
child process started successfully, parent exiting
[root@leco mongo]# ps axf|grep mongod
18963 pts/0    S+     0:00          \_ grep mongod
18924 ?        Sl     0:00 mongod -f /usr/local/mongo/conf/mongodb.conf
[root@leco mongo]# netstat -lnp|grep 27017
tcp        0      0 0.0.0.0:27017               0.0.0.0:*                   LISTEN      18924/mongod
unix  2      [ ACC ]     STREAM     LISTENING     66911078 18924/mongod        /tmp/mongodb-27017.sock
[root@leco mongo]#</code></pre>
<p>配置文件解释</p>
<pre class=" language-python"><code class="language-python">dbpath <span class="token operator">=</span> <span class="token operator">/</span>usr<span class="token operator">/</span>local<span class="token operator">/</span>mongodb<span class="token operator">/</span>data<span class="token operator">/</span>db            <span class="token comment" spellcheck="true"># 数据文件存放目录</span>
logpath <span class="token operator">=</span> <span class="token operator">/</span>usr<span class="token operator">/</span>local<span class="token operator">/</span>mongodb<span class="token operator">/</span>logs<span class="token operator">/</span>mongodb<span class="token punctuation">.</span>log  <span class="token comment" spellcheck="true"># 日志文件存放目录</span>
port <span class="token operator">=</span> <span class="token number">27017</span>                                   <span class="token comment" spellcheck="true"># 端口</span>
fork <span class="token operator">=</span> true                                    <span class="token comment" spellcheck="true"># 以守护程序的方式启用，即在后台运行</span>
bind_ip<span class="token operator">=</span><span class="token number">0.0</span><span class="token punctuation">.</span><span class="token number">0.0</span>                                <span class="token comment" spellcheck="true"># 允许所有的连接</span></code></pre>
<h3 id="2-6-docker安装"><a href="#2-6-docker安装" class="headerlink" title="2.6 docker安装"></a>2.6 docker安装</h3><pre><code>docker pull mongo
docker run -itd --name=mongo_test -p 27017:27017 mongo</code></pre><h2 id="3-概念介绍"><a href="#3-概念介绍" class="headerlink" title="3. 概念介绍"></a>3. 概念介绍</h2><p>&emsp;&emsp;在mongodb中基本的概念是文档、集合、数据库，在其他NoSQL中对比</p>
<table>
<thead>
<tr>
<th>SQL术语/概念</th>
<th>MongoDB术语/概念</th>
<th>解释/说明</th>
</tr>
</thead>
<tbody><tr>
<td>database</td>
<td>database</td>
<td>数据库</td>
</tr>
<tr>
<td>table</td>
<td>collection</td>
<td>数据库表/集合</td>
</tr>
<tr>
<td>row</td>
<td>document</td>
<td>数据记录行/文档</td>
</tr>
<tr>
<td>column</td>
<td>field</td>
<td>数据字段/域</td>
</tr>
<tr>
<td>index</td>
<td>index</td>
<td>索引</td>
</tr>
<tr>
<td>table joins</td>
<td></td>
<td>表连接,MongoDB不支持</td>
</tr>
<tr>
<td>primary key</td>
<td>primary key</td>
<td>主键,MongoDB自动将_id字段设置为主键</td>
</tr>
</tbody></table>
<h3 id="3-1-数据库"><a href="#3-1-数据库" class="headerlink" title="3.1 数据库"></a>3.1 数据库</h3><p>&emsp;&emsp;一个mongodb中可以建立多个数据库。</p>
<p>&emsp;&emsp;MongoDB的默认数据库为”db”，该数据库存储在data目录中。</p>
<p>&emsp;&emsp;MongoDB的单个实例可以容纳多个独立的数据库，每一个都有自己的集合和权限，不同的数据库也放置在不同的文件中。</p>
<p>&emsp;&emsp;”show dbs” 命令可以显示所有数据的列表。</p>
<pre class=" language-shell"><code class="language-shell">[root@leco mongo]# mongo
MongoDB shell version v4.0.6
sconnecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb                                                                                                                        sho^HsImplicit session: session { "id" : UUID("6b210996-2e69-4e35-bd6d-7ee0a946cdc5") }
^H^H^H^H^HMongoDB server version: 4.0.6
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
    http://docs.mongodb.org/
Questions? Try the support group
    http://groups.google.com/group/mongodb-user
Server has startup warnings:
2019-02-27T09:59:22.485+0800 I STORAGE  [initandlisten]
2019-02-27T09:59:22.485+0800 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-02-27T09:59:22.485+0800 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-02-27T09:59:23.449+0800 I CONTROL  [initandlisten]
2019-02-27T09:59:23.449+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2019-02-27T09:59:23.449+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2019-02-27T09:59:23.449+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2019-02-27T09:59:23.449+0800 I CONTROL  [initandlisten]
2019-02-27T09:59:23.450+0800 I CONTROL  [initandlisten]
2019-02-27T09:59:23.450+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2019-02-27T09:59:23.450+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-02-27T09:59:23.451+0800 I CONTROL  [initandlisten]
2019-02-27T09:59:23.451+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2019-02-27T09:59:23.451+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2019-02-27T09:59:23.451+0800 I CONTROL  [initandlisten]
2019-02-27T09:59:23.451+0800 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 7424 processes, 65535 files. Number of processes should be at least 32767.5 : 0.5 times number of files.
2019-02-27T09:59:23.451+0800 I CONTROL  [initandlisten]
> show dbs;
admin   0.000GB
config  0.000GB
local   0.000GB</code></pre>
<p>执行 “db” 命令可以显示当前数据库对象或集合。运行”use”命令，可以连接到一个指定的数据库。</p>
<pre class=" language-sql"><code class="language-sql"><span class="token operator">></span> <span class="token number">db</span>
test
<span class="token operator">></span> <span class="token keyword">use</span> <span class="token keyword">local</span>
switched <span class="token keyword">to</span> <span class="token number">db</span> <span class="token keyword">local</span>
<span class="token operator">></span> <span class="token number">db</span>
<span class="token keyword">local</span></code></pre>
<p>以上实例命令中，”local” 是你要链接的数据库。</p>
<h3 id="3-2-特殊库"><a href="#3-2-特殊库" class="headerlink" title="3.2 特殊库"></a>3.2 特殊库</h3><ul>
<li>admin： 从权限的角度来看，这是”root”数据库。要是将一个用户添加到这个数据库，这个用户自动继承所有数据库的权限。一些特定的服务器端命令也只能从这个数据库运行，比如列出所有的数据库或者关闭服务器。</li>
<li>local: 这个数据永远不会被复制，可以用来存储限于本地单台服务器的任意集合</li>
<li>config: 当Mongo用于分片设置时，config数据库在内部使用，用于保存分片的相关信息。</li>
</ul>
<h3 id="3-3-文档"><a href="#3-3-文档" class="headerlink" title="3.3 文档"></a>3.3 文档</h3><p>&emsp;&emsp;文档是一组键值(key-value)对(即BSON)。MongoDB 的文档不需要设置相同的字段，并且相同的字段不需要相同的数据类型，这与关系型数据库有很大的区别，也是 MongoDB 非常突出的特点。</p>
<p>&emsp;&emsp;一个简单的文档例子如下：</p>
<pre class=" language-sql"><code class="language-sql">{<span class="token string">"site"</span>:"https:<span class="token comment" spellcheck="true">//caimengzhi.github.io/books/", "name":"cmz"}</span></code></pre>
<p>&emsp;&emsp;DBMS 与 MongoDB 对应的术语：</p>
<table>
<thead>
<tr>
<th>RDBMS</th>
<th>MongoDB</th>
</tr>
</thead>
<tbody><tr>
<td>数据库</td>
<td>数据库</td>
</tr>
<tr>
<td>表格</td>
<td>集合</td>
</tr>
<tr>
<td>行</td>
<td>文档</td>
</tr>
<tr>
<td>列</td>
<td>字段</td>
</tr>
<tr>
<td>表联合</td>
<td>嵌入文档</td>
</tr>
<tr>
<td>主键</td>
<td>主键 (MongoDB 提供了 key 为 _id )</td>
</tr>
</tbody></table>
<p>注意</p>
<pre class=" language-python"><code class="language-python"><span class="token number">1</span><span class="token punctuation">.</span> 文档中的键<span class="token operator">/</span>值对是有序的。
<span class="token number">2</span><span class="token punctuation">.</span> 文档中的值不仅可以是在双引号里面的字符串，还可以是其他几种数据<span class="token number">3</span><span class="token punctuation">.</span> 类型（甚至可以是整个嵌入的文档<span class="token punctuation">)</span>。
<span class="token number">4</span><span class="token punctuation">.</span> MongoDB区分类型和大小写。
<span class="token number">5</span><span class="token punctuation">.</span> MongoDB的文档不能有重复的键。
<span class="token number">6</span><span class="token punctuation">.</span> 文档的键是字符串。除了少数例外情况，键可以使用任意UTF<span class="token number">-8</span>字符。
<span class="token number">7</span><span class="token punctuation">.</span> 键不能含有\<span class="token number">0</span> <span class="token punctuation">(</span>空字符<span class="token punctuation">)</span>。这个字符用来表示键的结尾。
<span class="token number">8</span><span class="token punctuation">.</span> <span class="token punctuation">.</span>和$有特别的意义，只有在特定环境下才能使用。
<span class="token number">9</span><span class="token punctuation">.</span> 以下划线<span class="token string">"_"</span>开头的键是保留的<span class="token punctuation">(</span>不是严格要求的<span class="token punctuation">)</span></code></pre>
<h3 id="3-4-集合"><a href="#3-4-集合" class="headerlink" title="3.4 集合"></a>3.4 集合</h3><h4 id="3-4-1-介绍"><a href="#3-4-1-介绍" class="headerlink" title="3.4.1 介绍"></a>3.4.1 介绍</h4><p>&emsp;&emsp;集合就是 MongoDB 文档组，类似于 RDBMS （关系数据库管理系统：Relational Database Management System)中的表格。集合存在于数据库中，集合没有固定的结构，这意味着你在对集合可以插入不同格式和类型的数据，但通常情况下我们插入集合的数据都会有一定的关联性。</p>
<p>&emsp;&emsp;比如，我们可以将以下不同数据结构的文档插入到集合中：</p>
<pre class=" language-sql"><code class="language-sql">{<span class="token string">"site"</span>:"https:<span class="token comment" spellcheck="true">//caimengzhi.github.io/books/"}</span>
{<span class="token string">"site"</span>:"https:<span class="token comment" spellcheck="true">//caimengzhi.github.io/books/","name":"cmz"}</span>
{<span class="token string">"site"</span>:"https:<span class="token comment" spellcheck="true">//caimengzhi.github.io/books/","name":"cmz","num":66}</span></code></pre>
<p>当第一个文档插入时，集合就会被创建。</p>
<h4 id="3-4-2-合法的集合名"><a href="#3-4-2-合法的集合名" class="headerlink" title="3.4.2 合法的集合名"></a>3.4.2 合法的集合名</h4><ul>
<li>集合名不能是空字符串””。</li>
<li>集合名不能含有\0字符（空字符)，这个字符表示集合名的结尾。</li>
<li>集合名不能以”system.”开头，这是为系统集合保留的前缀。</li>
<li>用户创建的集合名字不能含有保留字符。有些驱动程序的确支持在集合名里面包含，这是因为某些系统生成的集合中包含该字符。除非你要访问这种系统创建的集合，否则千万不要在名字里出现$。　</li>
</ul>
<h3 id="3-5-元数据"><a href="#3-5-元数据" class="headerlink" title="3.5 元数据"></a>3.5 元数据</h3><p>&emsp;&emsp;数据库的信息是存储在集合中。它们使用了系统的命名空间：</p>
<pre class=" language-sql"><code class="language-sql">dbname<span class="token punctuation">.</span>system<span class="token punctuation">.</span><span class="token operator">*</span></code></pre>
<h2 id="4-数据类型"><a href="#4-数据类型" class="headerlink" title="4 数据类型"></a>4 数据类型</h2><p>&emsp;&emsp;下表为MongoDB中常用的几种数据类型。</p>
<table>
<thead>
<tr>
<th>数据类型</th>
<th>描述</th>
</tr>
</thead>
<tbody><tr>
<td>String</td>
<td>字符串。存储数据常用的数据类型。在 MongoDB 中，UTF-8 编码的字符串才是合法的。</td>
</tr>
<tr>
<td>Integer</td>
<td>整型数值。用于存储数值。根据你所采用的服务器，可分为 32 位或 64 位。</td>
</tr>
<tr>
<td>Boolean</td>
<td>布尔值。用于存储布尔值（真/假）。</td>
</tr>
<tr>
<td>Double</td>
<td>双精度浮点值。用于存储浮点值。</td>
</tr>
<tr>
<td>Min/Max keys</td>
<td>将一个值与 BSON（二进制的 JSON）元素的最低值和最高值相对比。</td>
</tr>
<tr>
<td>Array</td>
<td>用于将数组或列表或多个值存储为一个键。</td>
</tr>
<tr>
<td>Timestamp</td>
<td>时间戳。记录文档修改或添加的具体时间。</td>
</tr>
<tr>
<td>Object</td>
<td>用于内嵌文档。</td>
</tr>
<tr>
<td>Null</td>
<td>用于创建空值。</td>
</tr>
<tr>
<td>Symbol</td>
<td>符号。该数据类型基本上等同于字符串类型，但不同的是，它一般用于采用特殊符号类型的语言。</td>
</tr>
<tr>
<td>Date</td>
<td>日期时间。用 UNIX 时间格式来存储当前日期或时间。你可以指定自己的日期时间：创建 Date 对象，传入年月日信息。</td>
</tr>
<tr>
<td>Object ID</td>
<td>对象 ID。用于创建文档的 ID。</td>
</tr>
<tr>
<td>Binary Data</td>
<td>二进制数据。用于存储二进制数据。</td>
</tr>
<tr>
<td>Code</td>
<td>代码类型。用于在文档中存储 JavaScript 代码。</td>
</tr>
<tr>
<td>Regular expression</td>
<td>正则表达式类型。用于存储正则表达式。</td>
</tr>
</tbody></table>
<h3 id="4-1-ObjectId"><a href="#4-1-ObjectId" class="headerlink" title="4.1 ObjectId"></a>4.1 ObjectId</h3><p>&emsp;&emsp;ObjectId</p>
<ul>
<li>类似唯一主键，可以很快的去生成和排序，包含 12 bytes，含义是：</li>
<li>前 4 个字节表示创建 unix 时间戳,格林尼治时间 UTC 时间，比北京时间晚了 8 个小时</li>
<li>接下来的 3 个字节是机器标识码</li>
<li>紧接的两个字节由进程 id 组成 PID</li>
<li>最后三个字节是随机数</li>
</ul>
<pre class=" language-sql"><code class="language-sql"><span class="token number">0</span><span class="token operator">|</span><span class="token number">1</span><span class="token operator">|</span><span class="token number">2</span><span class="token operator">|</span><span class="token number">3</span><span class="token operator">|</span><span class="token number">4</span><span class="token operator">|</span><span class="token number">5</span><span class="token operator">|</span><span class="token number">6</span><span class="token operator">|</span><span class="token number">7</span><span class="token operator">|</span><span class="token number">8</span><span class="token operator">|</span><span class="token number">9</span><span class="token operator">|</span><span class="token number">10</span><span class="token operator">|</span><span class="token number">11</span>
       <span class="token operator">|</span>     <span class="token operator">|</span>   <span class="token operator">|</span>
时间戳 <span class="token operator">|</span>机器 <span class="token operator">|</span>PID<span class="token operator">|</span>计数器</code></pre>
<p>&emsp;&emsp;MongoDB 中存储的文档必须有一个 _id 键。这个键的值可以是任何类型的，默认是个 ObjectId 对象</p>
<p>&emsp;&emsp;由于 ObjectId 中保存了创建的时间戳，所以你不需要为你的文档保存时间戳字段，你可以通过 getTimestamp 函数来获取文档的创建时间:</p>
<pre class=" language-sql"><code class="language-sql"><span class="token operator">></span> var newObject <span class="token operator">=</span> ObjectId<span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token operator">></span> newObject<span class="token punctuation">.</span>getTimestamp<span class="token punctuation">(</span><span class="token punctuation">)</span>
ISODate<span class="token punctuation">(</span><span class="token string">"2019-02-27T02:24:17Z"</span><span class="token punctuation">)</span></code></pre>
<p>ObjectId 转为字符串</p>
<pre><code>&gt; newObject.str
5c75f4d1970254564966ebd4</code></pre><h3 id="4-2-字符串"><a href="#4-2-字符串" class="headerlink" title="4.2 字符串"></a>4.2 字符串</h3><p>&emsp;&emsp;BSON 字符串都是 UTF-8 编码。</p>
<h3 id="4-3-时间戳"><a href="#4-3-时间戳" class="headerlink" title="4.3 时间戳"></a>4.3 时间戳</h3><p>&emsp;&emsp;BSON 有一个特殊的时间戳类型用于 MongoDB 内部使用，与普通的 日期 类型不相关。 时间戳值是一个 64 位的值。其中：</p>
<ul>
<li>前32位是一个 time_t 值（与Unix新纪元相差的秒数）</li>
<li>后32位是在某秒中操作的一个递增的序数</li>
</ul>
<p>单个 mongod 实例中，时间戳值通常是唯一的。在复制集中， oplog 有一个 ts 字段。这个字段中的值使用BSON时间戳表示了操作时间。</p>
<h3 id="4-4-日期"><a href="#4-4-日期" class="headerlink" title="4.4 日期"></a>4.4 日期</h3><p>&emsp;&emsp;表示当前距离 Unix新纪元（1970年1月1日）的毫秒数。日期类型是有符号的, 负数表示 1970 年之前的日期。</p>
<pre class=" language-sql"><code class="language-sql"><span class="token operator">></span> var mydate1 <span class="token operator">=</span> new <span class="token keyword">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span>     <span class="token comment" spellcheck="true">//格林尼治时间</span>
<span class="token operator">></span> mydate1
ISODate<span class="token punctuation">(</span><span class="token string">"2019-02-27T02:27:17.952Z"</span><span class="token punctuation">)</span>
<span class="token operator">></span> typeof mydate1
object</code></pre>
<p>这样创建的时间是日期类型，可以使用 JS 中的 Date 类型的方法。<br>返回一个时间类型的字符串：</p>
<pre class=" language-sql"><code class="language-sql"><span class="token operator">></span> var mydate1str <span class="token operator">=</span> mydate1<span class="token punctuation">.</span>toString<span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token operator">></span> mydate1str
Wed Feb <span class="token number">27</span> <span class="token number">2019</span> <span class="token number">10</span>:<span class="token number">27</span>:<span class="token number">17</span> GMT<span class="token operator">+</span><span class="token number">0800</span> <span class="token punctuation">(</span>CST<span class="token punctuation">)</span>
<span class="token operator">></span> typeof mydate1str
string</code></pre>
<p>或者</p>
<pre class=" language-sql"><code class="language-sql"><span class="token operator">></span> <span class="token keyword">Date</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
Wed Feb <span class="token number">27</span> <span class="token number">2019</span> <span class="token number">10</span>:<span class="token number">29</span>:<span class="token number">06</span> GMT<span class="token operator">+</span><span class="token number">0800</span> <span class="token punctuation">(</span>CST<span class="token punctuation">)</span></code></pre>

            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://caimengzhi.gitee.io" rel="external nofollow noreferrer">夏天</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://caimengzhi.gitee.io/2020/03/23/nosql/mongo-index/">https://caimengzhi.gitee.io/2020/03/23/nosql/mongo-index/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="https://caimengzhi.gitee.io" target="_blank">夏天</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/tags/NoSQL/">
                                    <span class="chip bg-color">NoSQL</span>
                                </a>
                            
                                <a href="/tags/%E5%AD%A6%E4%B9%A0/">
                                    <span class="chip bg-color">学习</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
    #love{
       color:red; 
    }
    #page_over{
       height: 38px;
       text-align:center;
       font-size: 20px;
       line-height: 38px;
       background-color: #8FDFDB; 
    }
</style>

<div id="reward">
    <div id="page_over">--------本文结束感谢您的阅读!---------</div>
    <h4><span id="love">❤</span></span>如果文章能够帮到您的话，不妨就支持一下小编呗!<span id="love">❤</span></h4>
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>
            
        </div>
    </div>

    

    

    

    
    <div class="livere-card card" data-aos="fade-up">
    <!-- 来必力City版安装代码 -->
    <div id="lv-container" class="card-content" data-id="city" data-uid="MTAyMC80OTUxNS8yNjAwNgs">
        <script type="text/javascript">
            (function (d, s) {
                let j, e = d.getElementsByTagName(s)[0];
                if (typeof LivereTower === 'function') {
                    return;
                }

                j = d.createElement(s);
                j.src = 'https://cdn-city.livere.com/js/embed.dist.js';
                j.async = true;

                e.parentNode.insertBefore(j, e);
            })(document, 'script');
        </script>
        <noscript>为正常使用来必力评论功能请激活JavaScript。</noscript>
    </div>
    <!-- City版安装代码已完成 -->
</div>
    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/2020/03/23/nosql/mongo-index2/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/20.jpg" class="responsive-img" alt="MongoDB2 基本介绍">
                        
                        <span class="card-title">MongoDB2 基本介绍</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            MongoDB2 基本介绍
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2020-03-23
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/MongoDB/" class="post-category">
                                    MongoDB
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/NoSQL/">
                        <span class="chip bg-color">NoSQL</span>
                    </a>
                    
                    <a href="/tags/%E5%AD%A6%E4%B9%A0/">
                        <span class="chip bg-color">学习</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2020/03/21/english/english2/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/8.jpg" class="responsive-img" alt="单词">
                        
                        <span class="card-title">单词</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            名词
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2020-03-21
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/English/" class="post-category">
                                    English
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/%E5%8D%95%E8%AF%8D/">
                        <span class="chip bg-color">单词</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


<!-- 代码块折行 -->

<style type="text/css">
code[class*="language-"], pre[class*="language-"] { white-space: pre !important; }
</style>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>



    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        font-size: 15px;
        color: #42b983;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="503838841"
                   fixed='true'
                   autoplay='false'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>
    
    <div class="container row center-align" style="margin-bottom: 15px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            <span id="year">2019</span>
            <a href="https://caimengzhi.gitee.io" target="_blank">夏天</a>
            
            &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                class="white-color">39.7k</span>&nbsp;字
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
           
        
            
            <span id="sitetime">载入运行时间...</span>
            <script>
                function siteTime() {
                    var seconds = 1000;
                    var minutes = seconds * 60;
                    var hours = minutes * 60;
                    var days = hours * 24;
                    var years = days * 365;
                    var today = new Date();
                    var startYear = "2019";
                    var startMonth = "6";
                    var startDate = "28";
                    var startHour = "0";
                    var startMinute = "0";
                    var startSecond = "0";
                    var todayYear = today.getFullYear();
                    var todayMonth = today.getMonth() + 1;
                    var todayDate = today.getDate();
                    var todayHour = today.getHours();
                    var todayMinute = today.getMinutes();
                    var todaySecond = today.getSeconds();
                    var t1 = Date.UTC(startYear, startMonth, startDate, startHour, startMinute, startSecond);
                    var t2 = Date.UTC(todayYear, todayMonth, todayDate, todayHour, todayMinute, todaySecond);
                    var diff = t2 - t1;
                    var diffYears = Math.floor(diff / years);
                    var diffDays = Math.floor((diff / days) - diffYears * 365);
                    var diffHours = Math.floor((diff - (diffYears * 365 + diffDays) * days) / hours);
                    var diffMinutes = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours) /
                        minutes);
                    var diffSeconds = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours -
                        diffMinutes * minutes) / seconds);
                    if (startYear == todayYear) {
                        document.getElementById("year").innerHTML = todayYear;
                        document.getElementById("sitetime").innerHTML = "本站已安全运行 " + diffDays + " 天 " + diffHours +
                            " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                    } else {
                        document.getElementById("year").innerHTML = startYear + " - " + todayYear;
                        document.getElementById("sitetime").innerHTML = "本站已安全运行 " + diffYears + " 年 " + diffDays +
                            " 天 " + diffHours + " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒";
                    }
                }
                setInterval(siteTime, 1000);
            </script>
            
            <br>
            <script src="https://pv.sohu.com/cityjson?ie=utf-8"></script> 
            <script type="text/javascript">  
                document.write('欢迎来自:' + returnCitySN["cname"]+'的朋友' + ",您的IP:" + returnCitySN["cip"] + ",浏览器版本:"+getBrowserInfo());
                function getBrowserInfo()
                {
                    var agent = navigator.userAgent.toLowerCase() ;
                    var regStr_ie = /msie [\d.]+;/gi ;
                    var regStr_ff = /firefox\/[\d.]+/gi
                    var regStr_chrome = /chrome\/[\d.]+/gi ;
                    var regStr_saf = /safari\/[\d.]+/gi ;
                    //IE
                    if(agent.indexOf("msie") > 0)
                    {
                        return agent.match(regStr_ie) ;
                    }
                    //firefox
                    if(agent.indexOf("firefox") > 0)
                    {
                        return agent.match(regStr_ff) ;
                    }
                    //Chrome
                    if(agent.indexOf("chrome") > 0)
                    {
                        return agent.match(regStr_chrome) ;
                    }
                    //Safari
                    if(agent.indexOf("safari") > 0 && agent.indexOf("chrome") < 0)
                    {
                        return agent.match(regStr_saf) ;
                    }
                }
            </script> 
        
            
            <span id="icp"><img src="/medias/icp.png" style="vertical-align: text-bottom;" />
                <a href="https://caimengzhi.gitee.io/books/" target="_blank">爱一直在线</a>
            </span>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://caimengzhi.gitee.io/books/" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:610658552@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=QQ 联系我 610658552" class="tooltipped" target="_blank" data-tooltip="QQ联系我: QQ 联系我 610658552" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>





    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
});
</script>
    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    
   
    

    
    
    <script>
        (function (i, s, o, g, r, a, m) {
            i["DaoVoiceObject"] = r;
            i[r] = i[r] || function () {
                (i[r].q = i[r].q || []).push(arguments)
            }, i[r].l = 1 * new Date();
            a = s.createElement(o), m = s.getElementsByTagName(o)[0];
            a.async = 1;
            a.src = g;
            a.charset = "utf-8";
            m.parentNode.insertBefore(a, m)
        })(window, document, "script", ('https:' == document.location.protocol ? 'https:' : 'http:') +
            "//widget.daovoice.io/widget/6984b559.js", "daovoice")
        daovoice('init', {
            app_id: "29275150"
        });
        daovoice('update');
    </script>
    

    
    <script type="text/javascript" color="0,0,255"
        pointColor="0,0,255" opacity='0.7'
        zIndex="-1" count="99"
        src="/libs/background/canvas-nest.js"></script>
    

    

    
    <script type="text/javascript" src="/libs/background/ribbon-dynamic.js" async="async"></script>
    
    
    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    
    <!-- caimengzhi 
    <div id="weather-view-he"></div>
    -->
    
<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>

</html>

<script type="text/javascript">
//只在桌面版网页启用特效
var windowWidth = $(window).width();
if (windowWidth > 768) {
    document.write('<script type="text/javascript" src="/js/sakura.js"><\/script>');
}
</script>


<!--<script type="text/javascript" src="/js/click_show_text.js"></script>-->
<script type="text/javascript" src="/js/FunnyTitle.js"></script>

<canvas class="fireworks" style="position: fixed;left: 0;top: 0;z-index: 1; pointer-events: none;" ></canvas> 
<script type="text/javascript" src="//cdn.bootcss.com/animejs/2.2.0/anime.min.js"></script> 
<!--<script type="text/javascript" src="/js/fireworks.js"></script>-->
<script type="text/javascript" src="/js/cursor.js"></script>

<!-- summer -->
<script type="text/javascript">
WIDGET = {FID: '5bDQrVS13z'}
</script>
<script type="text/javascript" src="https://apip.weatherdt.com/float/static/js/r.js?v=1111"></script>